import Vue from 'vue'
import api from "./api"
const {
    $Toast
} = require("@/../static/iview/base/index");

const request = {
    async getIndexIndex(data) {
        // 请求多用户首页列表
        let res = await api.get('shop/index-index', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getLocationName(data) {
        // let amapKey = 'c57fd7a445e56f3983b626de4a9c71b5'
        // console.log(data)
        // console.log(`https://restapi.amap.com/v3/assistant/coordinate/convert?locations=${data.longitude},${data.latitude}&coordsys=gps&output=json&key=${amapKey}`)
        // let res = await api.get(`https://restapi.amap.com/v3/assistant/coordinate/convert?locations=${data.longitude},${data.latitude}&coordsys=gps&output=json&key=${amapKey}`)
        // console.log(res,'enenenenenene')
        // console.log(`https://restapi.amap.com/v3/geocode/regeo?output=json&location=${res.locations.split(',')[0]},${res.locations.split(',')[1]}&key=${amapKey}&radius=1000&extensions=all&batch=false`)
        // let resend = await api.get(`https://restapi.amap.com/v3/geocode/regeo?output=json&location=${res.locations.split(',')[0]},${res.locations.split(',')[1]}&key=${amapKey}&radius=1000&extensions=all&batch=false`)
        // console.log(resend,'enenenenenene')
        // console.log(2222)
        // return new Promise((resolve, reject) => {
        //     if (resend) {
        //         resolve(resend)
        //     } else {
        //         reject(resend)
        //     }
        // })
        let res = await api.get(`https://api.map.baidu.com/geocoder/v2/?location=${data.latitude},${data.longitude}&output=json&pois=1&ak=QkRtmyjYnGe45DNMN7uUTjY0U5i8FA8j`, data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getMallStoreList(data) {
        // 请求商家列表
        let res = await api.get('shop/mall-store-list', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getMallStoreDetail(data) {
        // 请求商家详情
        let res = await api.get('shop/mall-store-detail', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getMallStoreGoods(data) {
        // 请求商家全部商品
        let res = await api.get('shop/mall-store-goods', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getMallStoreCates(data) {
        // 请求商家全部分类
        let res = await api.get('shop/mall-store-cates', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getMallList(data) {
        // 请求商品分类列表
        let res = await api.get('shop/mall-lists', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getMallGoodsDetail(data) {
        // 请求商品详情
        let res = await api.get('shop/mall-goods-detail', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getMallAddCart(data) {
        // 添加到购物车
        let res = await api.post('shop/order-add-cart', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getMallCartList(data) {
        // 获取购物车列表
        let res = await api.get('shop/order-cart-list', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async delMallCart(data) {
        // 删除指定购物车内容
        let res = await api.post('shop/order-cart-del', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getMallCollect(data) {
        // 添加到收藏
        let res = await api.post('shop/mall-goods-add-collect', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },

    /**
     *
     * ? 取消商品收藏
     * * @goods_id  Int  商品ID
     */
    async cancelCollect(data) {
        let res = await api.post('shop/mall-goods-cancel-collect', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getUserInfo(data) {
        // 获取用户信息
        let res = await api.get('member/user-my-info', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getCollects(data) {
        // 获取用户收藏列表
        let res = await api.get('member/user-my-collects', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getNewsList(data) {
        // 获取专题列表
        let res = await api.get('shop/news-lists', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getNewsDetail(data) {
        // 获取专题详情
        let res = await api.get('shop/news-detail', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getAddressList(data) {
        // 获取地址列表
        let res = await api.get('member/user-my-address', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async postAddress(data) {
        // 获取地址列表
        let res = await api.post('member/user-address-add-edit', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async deleteAddress(data) {
        // 删除地址
        let res = await api.post('member/user-address-del', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getProductList(data) {
        // 获取分类下商品列表
        let res = await api.get('shop/mall-goods-list', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getCouponsList(data) {
        // 获取分类下商品列表
        let res = await api.get('member/user-my-coupons', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getSelfShipping(data) {
        // 获取自提地址
        let res = await api.get('shop/mall-self-shipping', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getOrderSubmit(data) {
        // 提交订单
        let res = await api.post('shop/order-info-submit', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getOrderList(data) {
        // 订单列表
        let res = await api.get('member/user-order-list', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    /**
     * ? 用户中心模块 - 订单操作
     * * @type  Iny  操作类型 1-取消订单 2-确认收货 3-退货
     * * @orderId  Int  订单id
     */
    async handleOrder(data) {
        let res = await api.post('member/user-order-handle', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },

    async getOrderInfo(data) {
        // 订单详情
        let res = await api.get('member/user-order-detail', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getPoints(data) {
        // 获取积分或者余额流水
        let res = await api.get('member/user-points-money-logs', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getReds(data) {
        // 
        let res = await api.get('member/user-my-reds', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getSubsLists(data) {
        // 代发列表
        let res = await api.get('shop/subs-lists', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async submitsSubsOrder(data) {
        // 提交代发
        let res = await api.post('shop/subs-submit-order', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async delSubsSinge(data) {
        // 代发删除        
        let res = await api.post('shop/subs-singe-del', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getSbsOrderLists(data) {
        // 代发清单列表
        let res = await api.get('shop/subs-order-lists', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async postSubsSingeDddEdit(data) {
        // 编辑代发
        let res = await api.post('shop/subs-singe-add-edit', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getSubsOrderDetail(data) {
        // 获取代发详情
        let res = await api.get('shop/subs-order-detail', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async submitAuth(data) {
        // 提交认证
        let res = await api.post('member/user-submit-auth', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async sendCode(data) {
        // 发送验证，啊
        let res = await api.post('member/user-send-code', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getRechargeMethods(data) {
        // 获取充值方式
        let res = await api.get('member/user-recharge-methods', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async submitRecharge(data) {
        // 提交充值
        let res = await api.post('member/user-do-recharge', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async payConfirmMoney(data) {
        // 支付前获取的价格
        console.log(data)
        let res = await api.post('shop/pay-confirm-money', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async pay(data) {
        // 提交支付
        console.log(data)
        let res = await api.post('shop/pay-do-pay', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getAccessToken(data) {
        // 获取openid
        let res = await api.post('oauth/access_token', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async submitComment(data) {
        // 获取openid
        let res = await api.post('member/user-add-comment', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async storeCollect(data) {
        // 添加店铺到收藏
        let res = await api.post('shop/mall-store-add-collect', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async cancelStoreCollect(data) {
        // 取消店铺收藏
        let res = await api.post('shop/mall-store-cancel-collect', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getPointsGoodsLists(data) {
        // 积分商城模块 - 积分列表
        let res = await api.get('shop/points-goods-lists', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async pointsSubmitOrder(data) {
        // 积分商城模块 - 兑换
        let res = await api.post('shop/points-submit-order', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async pointsOrderList(data) {
        // 积分订单列表
        let res = await api.get('shop/points-order-lists', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async pointsConfirmOrder(data) {
        // 积分商城模块 - 确认
        let res = await api.get('shop/points-confirm-order', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async pointsGoodsDetail(data) {
        // 积分商城模块 - 积分详情
        let res = await api.get('shop/points-goods-detail', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async pointsOrderDetail(data) {
        // 积分商城模块 - 积分兑换详情
        let res = await api.get('shop/points-order-detail', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async serviceApplyStore(data) {
        // 入驻
        let res = await api.post('member/service-apply-store', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async serviceStoreCates(data) {
        // 店铺分类
        let res = await api.get('member/service-store-cates', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async sendCode(data) {
        // 发送验证码
        let res = await api.post('common/send-code', data)
        console.log(res)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async verifyCode(data) {
        // 验证验证码
        let res = await api.post('common/verify-code', data)
        console.log(res)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getDistributGoods(data) {
        // 获取分销商品与个人中心统计
        let res = await api.get('member/distribut-get-goods', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getDistributIncomeList(data) {
        // 获取分销收入列表
        let res = await api.get('member/distribut-income-list', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getDistributTeamList(data) {
        // 获取我的团队列表
        let res = await api.get('member/distribut-team-list', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getCoupons(data) {
        // 获取优惠券
        let res = await api.post('member/user-get-coupons', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getServiceSysTags(data) {
        // 获取系统标签
        let res = await api.get('member/service-sys-tags', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getStoreSeller(data) {
        // 卖家用户信息
        let res = await api.get('seller/user-my-info', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getStoreOrderList(data) {
        // 卖家订单列表
        let res = await api.get('seller/user-order-list', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getGoodsInfos(data) {
        // 获取商品分类品牌等相关信息
        let res = await api.get('seller/get-goods-infos', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async addAndEditCoupon(data) {
        // 优惠券添加与修改
        let res = await api.post('seller/add-and-edit-coupon', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getStoreCoupons(data) {
        // 获取商家优惠券
        let res = await api.post('seller/my-store-coupons', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
    async getServiceStoreCheck(data) {
        // 店铺申请之前的检测
        let res = await api.get('member/service-store-check', data)
        return new Promise((resolve, reject) => {
            if (res) {
                resolve(res)
            } else {
                reject(res)
            }
        })
    },
}

export default request
